import {createApp} from "vue";
import AppInstance from "./App.vue";
import {createPinia} from 'pinia';
import router from "@/plugins/router";

// 额外引入图标库
import ArcoVue from "@arco-design/web-vue";
import ArcoVueIcon from "@arco-design/web-vue/es/icon";
import VxeUIAll from "vxe-pc-ui";
import VxeUITable from "vxe-table";

// 引入样式
import "@/assets/less/theme.less";
import "@/components/view/JsonTreeView/index.less";
import "@arco-design/web-vue/dist/arco.css";
import "vxe-table/lib/style.css";
import "virtual:uno.css";
import "tdesign-vue-next/es/style/index.css";
import "@imengyu/vue3-context-menu/lib/vue3-context-menu.css";
import "vxe-table/es/style.css";
import "vxe-pc-ui/es/style.css";
import 'splitpanes/dist/splitpanes.css';

// Monaco Editor 注册语言
import * as monaco from "monaco-editor";
import {language} from "@/components/rest-client-editor/language";
import configuration from "@/components/rest-client-editor/configuration";
import provider from "@/components/rest-client-editor/provider";
import {restFoldingRangeProvider} from "@/components/rest-client-editor/foldingRange";


// 注册语言服务器
monaco.languages.register({id: "http"});
// 语法高亮
monaco.languages.setMonarchTokensProvider("http", language);
// 语言配置
monaco.languages.setLanguageConfiguration("http", configuration);
// TODO: 语法提示
monaco.languages.registerCompletionItemProvider("http", provider);
// 代码折叠
monaco.languages.registerFoldingRangeProvider("http", restFoldingRangeProvider);

window.addEventListener("message", (event) => {
  const message = event.data;
  if (message["type"] === "url-open") {
    sessionStorage.setItem("action", message["content"]);
  }
});

// 插件
createApp(AppInstance)
  .use(ArcoVue)
  .use(VxeUIAll)
  .use(VxeUITable)
  .use(createPinia())
  .use(ArcoVueIcon)
  .use(router)
  .mount("#app");

// 变量挂载
window.mode = import.meta.env.VITE_MODE;
window.referrer = import.meta.env.VITE_REFERRER;
